FUNCTION ZFIFM_INV_QUERY_CHECK_LIST.
*"----------------------------------------------------------------------
*"*"本地接口：
*"  IMPORTING
*"     VALUE(IS_CONTENT) TYPE  ZCL_DT_QUERY_INV_CHECKLIST_RE2
*"  EXPORTING
*"     VALUE(ES_MSG) TYPE  BAPIRET2
*"     VALUE(ET_INV_CHECK_LIST) TYPE  ZCL_DT_QUERY_INV_CHECKLIS_TAB1
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
  DATA:
    LO_PI    TYPE REF TO ZCL_CO_SI_SAP2NONO_QUERYINVCHE,
    LS_OUT   TYPE ZCL_MT_QUERY_INV_CHECKLIST_REQ,
    LS_INPUT TYPE ZCL_MT_QUERY_INV_CHECKLIST_RES.

  DATA:
    LV_UUID_C32 TYPE SYSUUID_C32,
    LV_TS       TYPE STRING.

  DATA: LV_SIZE       TYPE I VALUE '50',
        LV_CURR_PAGE  TYPE I,
        LV_TOTAL_PAGE TYPE I.

  DATA:
    LS_INV_DATA TYPE ZCL_DT_QUERY_INV_CHECKLIST_REQ,
    LT_INV_DATA TYPE ZCL_DT_QUERY_INV_CHECKLIST_TAB.

  ZIRPSAVE1: 'ZFIFM_INV_QUERY_CHECK_LIST'. "Log

  REFRESH ET_INV_CHECK_LIST[].

  CLEAR ES_MSG.
  PERFORM FRM_GET_CONFIG CHANGING ES_MSG.
  IF ES_MSG-TYPE = 'E'.

    APPEND ES_MSG TO RETURN.
    ZIRPSAVE2: CX_R SPACE.
    RETURN.
  ENDIF.

  TRY .
      CREATE OBJECT LO_PI.
    CATCH CX_AI_SYSTEM_FAULT INTO DATA(LR_CX_AI).
      ES_MSG-TYPE = 'E'.
      ES_MSG-MESSAGE = LR_CX_AI->GET_TEXT( ).

      APPEND ES_MSG TO RETURN.
      ZIRPSAVE2: CX_R SPACE.
      RETURN.
  ENDTRY.

  CLEAR:LV_CURR_PAGE.
  LV_CURR_PAGE =  1.

  DO.
    TRY.
*&--------清空变量
        CLEAR:LS_OUT,LS_INPUT.
*&--------获取GUID
        CLEAR:LV_UUID_C32.
        GO_TAX->GET_GUID( IMPORTING EV_GUID_32 = LV_UUID_C32 ).
*&--------获取时间戳
        CLEAR:LV_TS.
        GO_TAX->GET_TIMESTAMP( IMPORTING EV_TS = LV_TS ).

*&----------公有参数(消息头)
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT_TYPE    = ''.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-X_NUONUO_SIGN   = ''.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-ACCESS_TOKEN    = GO_TAX->MS_ZFIT043-ZTOKEN.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-TOKEN           = GO_TAX->MS_ZFIT043-ZTOKEN.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-TAXNUM          = GO_TAX->MS_ZFIT043-ZTAXNUM.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-USER_TAX        = GO_TAX->MS_ZFIT043-ZTAXNUM.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-METHOD          = 'nuonuo.OpeMplatform.queryInvChecklist'.
*&----------公有参数(消息体)
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-SENID           = LV_UUID_C32.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-NONCE           = '503208179'.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-TIMESTAMP       = LV_TS.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-APP_KEY         = GO_TAX->MS_ZFIT043-ZAPPKEY.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-APPKEY          = GO_TAX->MS_ZFIT043-ZAPPKEY.
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-APP_SECRET      = GO_TAX->MS_ZFIT043-ZAPPSECRET. "必填

*&---------私有参数
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT = IS_CONTENT.

        " 页码
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT-PAGE       = LV_CURR_PAGE.
        CONDENSE LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT-PAGE NO-GAPS.
        " 每页数据量
        LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT-SIZE           = LV_SIZE.
        CONDENSE LS_OUT-MT_QUERY_INV_CHECKLIST_REQ-CONTENT-SIZE NO-GAPS .

        CALL METHOD LO_PI->SI_SAP2NONO_QUERYINVCHECKLIST
          EXPORTING
            OUTPUT = LS_OUT
          IMPORTING
            INPUT  = LS_INPUT.

        CONDENSE LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-CODE.

        IF LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-CODE = GC_NONO_RET_CODE_E0000.
          ES_MSG-TYPE = 'S'.
          APPEND LINES OF LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-RESULT-DATA TO ET_INV_CHECK_LIST.

        ELSE.
          ES_MSG-TYPE = 'E'.
          ES_MSG-MESSAGE = LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-DESCRIBE.
          EXIT.
        ENDIF.

        IF LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-RESULT-TOTAL MOD LV_SIZE = 0.
          LV_TOTAL_PAGE = LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-RESULT-TOTAL / LV_SIZE.
        ELSE.
          LV_TOTAL_PAGE = LS_INPUT-MT_QUERY_INV_CHECKLIST_RES-RESULT-TOTAL DIV LV_SIZE.
          LV_TOTAL_PAGE = LV_TOTAL_PAGE + 1.
        ENDIF.

        IF LV_CURR_PAGE >= LV_TOTAL_PAGE OR
           LV_TOTAL_PAGE = 0.
          EXIT. " 当前页码大于等于总页码时,退出接口调用
        ENDIF.

        LV_CURR_PAGE = LV_CURR_PAGE + 1.

      CATCH CX_ROOT INTO DATA(LR_ERROR).
        ES_MSG-TYPE = 'E'.
        ES_MSG-MESSAGE =  LR_ERROR->GET_TEXT( ).

        EXIT.
    ENDTRY.

  ENDDO.

  APPEND ES_MSG TO RETURN.
  ZIRPSAVE2: CX_R SPACE.
ENDFUNCTION.
